package com.ce.source.analysis.lifecycle.spring;

import com.ce.source.analysis.lifecycle.spring.code.Person;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author ：前世小和尚（xiaopingzhang8@creditease.cn）
 * @Description ：spring启动
 * @ClassName ：SpringStartUp
 * @Company ：普信恒业科技发展（北京）有限公司
 * @date ：2018/1/29 13:11
 */
public class SpringStartUp {
    private static final Logger log = LoggerFactory.getLogger(SpringStartUp.class);
    public static void main(String[] args) {

//        ClassPathXmlApplicationContext context =  new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
//        context.start();
        ApplicationContext context =  new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
//        SpringLifeCycle cycle = (SpringLifeCycle) context.getBean("springLifeCycle");
//        cycle.sayHello();
        log.info("容器初始化成功");

        Person person =context.getBean("person", Person.class);
        log.info(person.toString());
        log.info("开始关闭容器");
        ((ClassPathXmlApplicationContext)context).registerShutdownHook();
    }
}
